﻿Imports IICBusinessLogic.DataConversion
Imports IICModel.DataConbversionLogic
Imports IICModel

Public Class ConversionMain

    Public Shared Sub main()

        Try
            ModelContext.newCurrent(New Model.ModelObjectPrincipal(Environment.UserName))
            Model.ModelContext.CurrentDBUtils = BaseDataConverter.newDBConnection

            DBUpdater.dbUpdateVersion(Model.ModelContext.CurrentDBUtils, _
                                      DBVersion.SYSTEM_DATABASE_VERSION, _
                                      GetType(IICModel.BusObjects.Lesson).Assembly)

            ModelContext.beginTrans()

            Dim d As New DASUpdate
            d.reverseAllDASPeriods()
            ModelContext.CurrentDBUtils.executeSQL("delete from [CertificationRequirement] where [CertificationTypeId] in (select CertificationTypeId from [CertificationType] where [DiplomaSuperTypeId]=5 and [CertificationType] like 'E%') ")
            ModelContext.CurrentDBUtils.executeSQL("delete from [CertificationType] where [DiplomaSuperTypeId]=5 and [CertificationType] like 'E%'")

            Dim dsm As New IICBusinessLogic.PasDasStructureManager()
            dsm.updateDASStructure()
            d.processDASPeriods()

        Finally
            ModelContext.commitTrans()
        End Try


    End Sub
End Class
